<?php
/**
 * OlliesPage.net
 * oPanel Installer Framework
 */

@set_time_limit(0);

//--------------------------------
// Setup
//--------------------------------

require( "./core/conf.php" );

//--------------------------------
// Define Constants
//--------------------------------

$INFO = array();

//--------------------------------
// Load our classes
//--------------------------------
require INS_ROOT_PATH   . 'core/classes/opclass.php';
require INS_ROOT_PATH   . 'core/classes/template.php';
require INS_ROOT_PATH . 'core/classes/class_xml.php';
require INS_ROOT_PATH   . 'core/classes/class_tar.php';

# Initiate super-class
$mainClass           = new mainClass();

//--------------------------------
//  Set up our vars
//--------------------------------

$mainClass->parse_incoming();

$mainClass->initiate_mainClass();	

//--------------------------------
// Setup Main Installer Class
//--------------------------------

require( INS_ROOT_PATH . 'core/classes/class_installer.php' );
require( INS_ROOT_PATH . 'custom/app.php' );

$install = new application_installer();
$install->mainClass =& $mainClass;
$install->read_config();

$install->template = new install_template( $mainClass );
$install->template->product_name         = $install->product_name;
$install->template->product_version      = $install->product_version;
$install->template->product_long_version = $install->product_long_version;

//--------------------------------
//  Saved Data
//--------------------------------
$install->saved_data = unserialize( urldecode( stripslashes( $_POST['saved_data'] ) ) );

//--------------------------------
// Test lock
//--------------------------------

if ( $mainClass->input['p'] != 'done' )
{
	$got_lock = $install->check_lock();
	
	if ( $got_lock )
	{
		$install->template->hide_next = 1;
		$install->template->warning( array( "This installer is locked. Via FTP please delete the file 'installfiles/lock.php' and then refresh this page." ) );
		$install->template->output( $install->product_name, $install->product_version );
		
		exit();
	}
}

// -------------------------------
// Run Install Step
// -------------------------------

$install->pre_process();
$install->process();
$install->post_process();

// -------------------------------
// Output
// -------------------------------
$install->template->saved_data = serialize( $install->saved_data );
$install->template->output( $install->product_name, $install->product_version );

?>